<%@ page import="com.demo1031.bean.Student" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: WuLiangHang
  Date: 2021/10/31
  Time: 10:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%
        request.setAttribute("arr", new String[]{"字符串A", "字符串B", "字符串C", "字符串D"});

        List<Student> students = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            students.add(new Student(i, "学生名字" + i, "密码" + i, 10 + i, "电话号码" + i));
        }
        request.setAttribute("students", students);

        Map<String, Object> map = new HashMap<>();
        map.put("key1", "value1");
        map.put("key2", "value2");
        map.put("key3", "value3");
        request.setAttribute("map", map);
    %>
</head>
<body>
<c:forEach begin="1" end="2" items="${requestScope.arr}" var="item">
    <h1>${item}</h1>
</c:forEach>
<table>
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>年龄</th>
        <th>电话</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${requestScope.students}" varStatus="status" var="student" begin="0" end="20" step="2">
        <tr>
            <td>${student.id}</td>
            <td>${student.username}</td>
            <td>${student.password}</td>
            <td>${student.age}</td>
            <td>${student.phone}</td>
            <td>${status.step}</td>
        </tr>
    </c:forEach>
</table>
<c:forEach items="${requestScope.map}" var="entry">
    <h1>${entry.key} = ${entry.value}</h1>
</c:forEach>
</body>
</html>
